package cn.edu.pku.action;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.edu.pku.dao.DepartmentDao;
import cn.edu.pku.dao.PositionDao;
import cn.edu.pku.dao.SalarystandardDao;
import cn.edu.pku.dao.TitleDao;
import cn.edu.pku.model.Department;
import cn.edu.pku.model.Position;
import cn.edu.pku.model.Salarystandard;
import cn.edu.pku.model.Title;

import com.opensymphony.xwork2.ActionSupport;

public class SearchSalarystandardAction extends ActionSupport implements BaseAction {
	/**
	 * 
	 */
	private HttpServletRequest request;
	private HttpServletResponse response;
	private Map att;

	private SalarystandardDao salarystandardDao;
	
	private List<Salarystandard> salarystandards;
	
	private String SearchMethod;
	private String salarystandardName;
	private double salary;

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub

		
		if (SearchMethod.equals("1")){
			salarystandards = salarystandardDao.findBySalarystandardName(salarystandardName);
		}
		else if (SearchMethod.equals("2")){
			salarystandards = salarystandardDao.findBySalary(salary);
		}
		request.setAttribute("total", salarystandards.size());
		return SUCCESS;
	}

	
	public String getSalarystandardName() {
		return salarystandardName;
	}


	public void setSalarystandardName(String salarystandardName) {
		this.salarystandardName = salarystandardName;
	}


	public double getSalary() {
		return salary;
	}


	public void setSalary(double salary) {
		this.salary = salary;
	}


	public String getSearchMethod() {
		return SearchMethod;
	}


	public void setSearchMethod(String searchMethod) {
		SearchMethod = searchMethod;
	}


	public List<Salarystandard> getSalarystandards() {
		return salarystandards;
	}


	public void setSalarystandards(List<Salarystandard> salarystandards) {
		this.salarystandards = salarystandards;
	}


	public SalarystandardDao getSalarystandardDao() {
		return salarystandardDao;
	}


	public void setSalarystandardDao(SalarystandardDao salarystandardDao) {
		this.salarystandardDao = salarystandardDao;
	}

	@Override
	public void setServletRequest(HttpServletRequest request) {
		// TODO Auto-generated method stub
		this.request = request;
	}

	@Override
	public void setServletResponse(HttpServletResponse response) {
		// TODO Auto-generated method stub
		this.response = response;
	}

	@Override
	public void setSession(Map att) {
		// TODO Auto-generated method stub
		this.att = att;
	}
}
